package final_wearebatman_view;

import final_wearebatman_model.OR_Gate;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;

public class OR_GateView implements Ipaintable {

    private OR_Gate orgate;
    private CircuitView circuitview;
    private int posX;
    private int posY;
    private int angle;
    private String name;

    // Kontrsuktor
    public OR_GateView(OR_Gate og, String name, CircuitView cv, int pX, int pY, int a) {
        this.orgate = og;
        this.circuitview = cv;
        this.posX = pX;
        this.posY = pY;
        this.angle = a;
        this.name = name;
    }

    // Kirajzolas
    public void paint(Graphics2D g) {
        AffineTransform aT = g.getTransform();
        g.translate(this.posX, this.posY);
        g.rotate(this.angle * Math.PI / 180);
        g.drawLine(0, 6, 13, 6);
        g.drawLine(0, 23, 13, 23);
        g.drawArc(-11, 1, 28, 27, -75, 150);
        g.drawLine(10, 2, 20, 2);
        g.drawLine(10, 27, 20, 27);
        g.drawArc(1, 2, 40, 25, -90, 180);
        g.drawLine(42, 15, 50, 15);
        g.setTransform(aT);
    }

    public int getPosX() {
        return this.posX;
    }

    public int getPosY() {
        return this.posY;
    }

    public int getAngle() {
        return this.angle;
    }

    public Point getInputPinPosition(int id) {
        if (id == 0) {
            return new Point(posX + 0, posY + 6);
        } else {
            return new Point(posX + 0, posY + 23);
        }
    }

    public Point getOutputPinPosition(int id) {
        return new Point(posX + 50, posY + 15);
    }

    public Rectangle getClickArea() {
        return new Rectangle();
    }

    public void onClick() {

    }
}
